package com.Blog.www.servlet;


import com.Blog.www.constant.DataConstant;
import com.Blog.www.po.User;
import com.Blog.www.service.FriendService;
import com.Blog.www.service.Impl.FriendServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 君未洋
 */
@WebServlet("/UserFriend/*")
public class FriendServlet extends BaseServlet {

    private static FriendService service = new FriendServiceImpl();

    public void userFriend(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
        Integer aid = Integer.parseInt(req.getParameter("aid"));
        //获取作者id
        //获取用户id
        User user = (User) req.getSession().getAttribute(DataConstant.USER_A);
        Integer status = Integer.parseInt(req.getParameter("status"));

        //调用service
        req = service.updateFriend(status, user.getId(), aid, req);
        //返回原页面
        req.getRequestDispatcher("/UserBlog/authorHome?id=" + aid + "&bid=" + req.getParameter("bid")).forward(req, resp);
    }
}
